<?php
/** 
 * $Source: /cvsroot/pn-commerce/pn-commerce/pntemplates/plugins/function.pncCountryDropdown.php,v $
 * $Author: klavs $
 * $Revision: 1.5 $
 * $Date: 2004/03/07 11:49:23 $
 *
 * Type: Function
 *
 * creates a complete dropdown field with all country names 
 *@param params['SelectedCountry']  string country name for preselection (might be empty)
 *@param params['City']     string name of the variable that will contain the selection
 *@return string complete <select></select statement with all options
 */
function smarty_function_pncCountryDropdown($params, &$smarty)
{
    extract( $params );
    if( !$VariableName )
    {  
        $smarty->trigger_error( "pncCountryDropDown: missing parameter VariableName" );
        return false;
    }
    else
    {  
        $countrylist = ""._PNC_COUNTRIES;
	    $countrylist = split(",", $countrylist);
	    array_push( $countrylist, pnVarPrepForDisplay(_PNC_USA) );
	    array_push( $countrylist, pnVarPrepForDisplay(_PNC_CANADA) );
	    asort( $countrylist );

        $select[$SelectedCountry] = 'selected';
	    $temp = "<select name='$VariableName' size='1'>\n";
    	foreach( $countrylist as $country )
	    {
	        $temp .= "<option value='$country' ".$select[$country].">$country</option>\n";
	    }
	    $temp .= "</select>\n";
	    return $temp;
    }
}

?>
